package com.zzw.hj75;

import java.util.Scanner;

/**
 * @Project: hw_java
 * @Description: 公共子串计算
 * @Author: zzw
 */

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String str1 = in.nextLine();
        String str2 = in.nextLine();
        if (str1.length() > str2.length()) {
            String str = str1;
            str1 = str2;
            str1 = str;
        }
        if (str2.contains(str1)) {
            System.out.println(str1.length());
            return;
        }
        // 滑动窗口
        for (int i = 1; i < str1.length(); i++) {
            for (int j = 0; j <= i; j++) {
                String str;
                str = str1.substring(j, str1.length() - (i - j));
                if (str2.contains(str)) {
                    System.out.println(str.length());
                    return;
                }
            }
        }
        System.out.println(0);

    }
}